package com.codeoss.framework.expression;

public class ExpressionUtil {
	public static Expression convertToExpression(String expressionString,String expressionType) {
		Expression expression=new Expression();
		expression.setScript(expressionString);
		expression.setScriptType(expressionType);
		return expression;
	}
	
	public static Expression convertLabelToExpression(String expressionString,String expressionType) {
		Expression expression=new Expression();
		if(Expression.EXPRESSION_TYPE_JAVASCRIPT.equals(expressionType)) {
			if(!expressionString.startsWith("'") && !expressionString.startsWith("\"") && expressionString.indexOf("(")==-1) {
				expressionString="'"+expressionString+"'";
			}
		}
		expression.setScript(expressionString);
		expression.setScriptType(expressionType);
		return expression;
	}
}
